<template>
	<view class="page mine_page">
		<view class="user_info" v-if="isLogin">
			<view class="info_phone">
				{{userInfo.no || '13888888888'}}
			</view>
			<view class="edit_btns">
				修改
			</view>
		</view>
		<view class="user_info" v-if="!isLogin" @click="login">
			<view class="info_phone">
				微信登录
			</view>
		</view>
		<view class="tips">
			与健康通行，健康生活一生
		</view>
		<view class="card">
			<view class="title">
				<view class="text">
					我的服务
				</view>
			</view>
			<view class="content_list">
				<view class="content_item">
					<view class="item_icon">
						<image src="@/static/icon/mine/wdwz-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						我的问诊
					</view>
				</view>
				<view class="content_item">
					<view class="item_icon">
						<image src="@/static/icon/mine/wdcf-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						我的处方
					</view>
				</view>
				<view class="content_item">
					<view class="item_icon">
						<image src="@/static/icon/mine/wdyy-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						我的预约
					</view>
				</view>
				<view class="content_item">
					<view class="item_icon">
						<image src="@/static/icon/mine/wdgz-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						我的关注
					</view>
				</view>
			</view>
		</view>
		<view class="card order">
			<view class="title" @click="gotoPage('/pagesCommon/order/orderList')">
				<view class="text">
					我的订单
				</view>
				<view class="more">
					查看全部
					<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
				</view>
			</view>
			<view class="content_list">
				<view class="content_item" @click="gotoPage(`/pagesCommon/order/orderList?status=${1}`)">
					<view class="item_icon">
						<image src="@/static/icon/mine/payment-1-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						待支付
					</view>
				</view>
				<view class="content_item" @click="gotoPage(`/pagesCommon/order/orderList?status=${2}`)">
					<view class="item_icon">
						<image src="@/static/icon/mine/payment-2-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						进行中
					</view>
				</view>
				<view class="content_item" @click="gotoPage(`/pagesCommon/order/orderList?status=${3}`)">
					<view class="item_icon">
						<image src="@/static/icon/mine/payment-3-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						已完成
					</view>
				</view>
				<view class="content_item" @click="gotoPage(`/pagesCommon/order/orderList?status=${4}`)">
					<view class="item_icon">
						<image src="@/static/icon/mine/payment-4-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						待评价
					</view>
				</view>
				<view class="content_item" @click="gotoPage(`/pagesCommon/order/orderList?status=${5}`)">
					<view class="item_icon">
						<image src="@/static/icon/mine/payment-5-icon.png" mode="heightFix"></image>
					</view>
					<view class="item_text">
						已取消
					</view>
				</view>
			</view>
		</view>
		<view class="card cell">
			<view class="cell_item" @click="gotoPage('/pagesCommon/patient/managementList?formPage=mine')">
				<view class="item_info">
					<view class="info_icon">
						<image src="../../static/icon/mine/hzgl-icon.png" mode="heightFix"></image>
					</view>
					<view class="info_name">
						患者管理
					</view>
				</view>
				<view class="item_more">
					<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
				</view>
			</view>
			<view class="cell_item" @click="gotoPage('/pagesCommon/case/caseList')">
				<view class="item_info">
					<view class="info_icon">
						<image src="@/static/icon/mine/blgl-icon.png" mode="heightFix"></image>
					</view>
					<view class="info_name">
						病例管理
					</view>
				</view>
				<view class="item_more">
					<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
				</view>
			</view>
			<view class="cell_item" @click="gotoPage('/pagesCommon/mine/complaint')">
				<view class="item_info">
					<view class="info_icon">
						<image src="@/static/icon/mine/tsjy-icon.png" mode="heightFix"></image>
					</view>
					<view class="info_name">
						投诉建议
					</view>
				</view>
				<view class="item_more">
					<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
				</view>
			</view>
			<view class="cell_item">
				<view class="item_info">
					<view class="info_icon">
						<image src="@/static/icon/mine/setting-icon.png" mode="heightFix"></image>
					</view>
					<view class="info_name">
						设置
					</view>
				</view>
				<view class="item_more">
					<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getToken,
		setToken,
		setUserOpenId,
		setUserInfo,
		getUserInfo
	} from '@/utils/auth.js'
	import {
		login
	} from '@/api/login.js'
	import {
		queryPatientInfo,
		getappinfo
	} from '@/api/index.js'
	export default {
		data() {
			return {
				isLogin: false,
				userInfo: getUserInfo()
			}
		},
		onShow() {
			this.isLogin = getToken()
		},
		methods: {
			gotoPage(url) {
				uni.navigateTo({
					url
				})
			},
			login() {
				uni.login({
					provider: "weixin",
					success: (loginRes) => {
						login({
							code: loginRes.code
						}).then(res => {
							setToken(res.data.appUserAuthLoginRespVO.accessToken)
							setUserOpenId(res.data.openId)
							return res.data.openId
						}).then((OpenId) => {
							queryPatientInfo().then(res => {
								setUserInfo(res.data)
								this.isLogin = true
								this.userInfo = res.data
							}).catch(err => {})
						}).then(res => {
							this.getappinfo()
						})
					}
				})
			},
			getappinfo() {
				getappinfo().then(res => {
					console.log(res)
				}).catch(err => {

				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.mine_page {

		.user_info {
			display: flex;
			align-items: center;

			.info_phone {
				font-weight: bold;
				font-size: 30rpx;
				color: #333333;
			}

			.edit_btns {
				margin-left: 20rpx;
				font-size: 24rpx;
				border: 1rpx solid #333333;
				border-radius: 100rpx;
				padding: 8rpx 20rpx;
			}
		}

		.tips {
			margin-top: 20rpx;
			margin-bottom: 55rpx;
			font-size: 24rpx;
			color: #999999;
		}

		.card {
			margin-bottom: 30rpx;

			.content_list {
				margin-top: 40rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.content_item {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.item_icon {
						width: 64rpx;
						height: 64rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.item_text {
						margin-top: 20rpx;
						font-size: 28rpx;
						color: #333333;
					}
				}
			}
		}

		.cell {
			.cell_item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 50rpx;

				&:last-child {
					margin: 0;
				}

				.item_info {
					flex: 0 0 80%;
					display: flex;
					align-items: center;

					.info_icon {
						flex: 0 0 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						height: 40rpx;
						margin-right: 10rpx;

						image {
							height: 40rpx;
						}
					}

					.info_name {
						flex: auto;
						font-size: 28rpx;
						color: #333333;
					}
				}
			}
		}


	}
</style>